#pragma once
#include "Common/IOCP.h"
#include "afxcmn.h"
#include "afxwin.h"
using namespace WY_IOCP;

class CUDP_IOCPDlg : public CDialogEx, public has_slots<>
{
public:
	CUDP_IOCPDlg(CWnd* pParent = NULL);

#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_UDP_IOCP_DIALOG };
#endif

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);

protected:
	HICON m_hIcon;

	CIOCP		_iocp;

	CEdit _editRecv;
	CEdit _editSend;
	CButton _btnSendMSG;
	CIPAddressCtrl _localAddr;

	CEdit _editLocalIpPort;
	CButton _btnConformLocal;

	CIPAddressCtrl _remoteAddr;
	CEdit _editRemotePort;
	CListBox _clientList;

	CString				_localIP;
	SRWLOCK				_srwConnectedSocketData;
	map<int, SocketData*> _connectedSocketData;

	CEdit				_editTest1;
	long				_testData1;
	long				_testFPS1;
	list<task<void>*>			_testTasks;
	cancellation_token_source*	_ctsTask1;

	virtual BOOL OnInitDialog();
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()

	void AppendMsg(const WCHAR* msg);
	LRESULT OnAppendMsg(WPARAM wParam, LPARAM lParam);
	void OnRecvMessage(SocketData* socketData, LocalPackage* localPackage);
	void OnRecvTest1(SocketData* socketData, LocalPackage* localPackage);
	LRESULT OnConnect(WPARAM wParam, LPARAM lParam);
	LRESULT OnDisconnect(WPARAM wParam, LPARAM lParam);

	void OnSignalNormalNotify(int type, int data, SocketData* socketData);
public:
	afx_msg void OnClose();
	afx_msg void OnBtnSendmsg();
	afx_msg void OnBtnBind();
	afx_msg void OnBtnConnect();
	afx_msg void OnBtnTest1();
	afx_msg void OnBtnShowTest1();
};
